<template>
  <div id="app">
    <el-container>
      <el-aside :width="width">
        <el-menu background-color="#545c64"
                 text-color="#fff"
                 active-text-color="#ffd04b">
          <el-menu-item index="3">
             <span slot="title" style="font:16px 微软雅黑;margin-left: -14px;">
              <span style="font:20px 华文行楷;color:deepskyblue">lhy</span> 后台管理
            </span>
          </el-menu-item>
        </el-menu>
        <el-menu
                :default-active="this.$route.path"
                router
                :collapse-transition="false"
                :collapse="collapse"
                background-color="#545c64"
                text-color="#fff"
                active-text-color="#ffd04b"
                class="el-menu-vertical-demo">
          <el-submenu index="1" v-for="menu in menus" :key="menu.index" >
            <template slot="title">
              <i :class="menu.icon"></i>
              <span>{{menu.title}}</span>
            </template>

            <el-menu-item :index="menu.path + '/'+ child.path" v-for="child in menu.children" :key="child.index">
               <span style="margin-left: 25px;">
                <i :class="child.icon"></i>
                {{child.title}}
               </span>
            </el-menu-item>

          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container>
        <el-header>
          <span :class="menuClass" @click="switchMenu"></span>
          <span class="con" >学生管理平台</span>
        </el-header>
        <el-main>
          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style>
  *{
    padding:0;
    margin:0;
  }
  .el-header, .el-footer {
    background-color: rgb(84,92,100);
    color: white;
    line-height: 60px;
    margin-left: 0;
    padding-left: 0;
  }
  .el-header .t{
    text-align: left;
  }
  .el-header .con{
    float: right;
  }
  .el-menu{
    border-right:0;
  }
  .el-aside {
    background-color: rgb(84,92,100);
    color: #333;
    text-align: center;
    line-height: 10px;
    height: 1500px;
  }

  .el-main {
    background-color: #E9EEF3;
    color: #333;
    line-height: 10px;
  }
</style>

<script>
  import menus from "../api/menus";
  export default {
    name: 'App',
    components: {

    },
    data(){
      return {
        menus:menus,
        collapse:false,
        width:'200px',
        menuClass:'t el-icon-s-fold',
      }
    },
    methods:{
      switchMenu(){
        //1. 修改菜单的折叠状态
        this.collapse = !this.collapse;
        //修改菜单宽度
        if (this.width == '200px'){
          this.width = '60px';
          this.menuClass = "t el-icon-s-fold"
        }else {
          this.width="200px";
          this.menuClass="t el-icon-s-unfold"
        }
      }
    }
  }
</script>
